<?php
	session_start();
	require("../inc/functions.php");
	if(!isEmployee())
		header("Location: ../index.php");
	require_once("../inc/models/contact_info_model.php");
	if(isset($_POST['submit'])){
		$row = $_POST;
		EditContactInfo($row);
		header("Location: index.php");
	}
	else{
		$results = GetContactInfo($_REQUEST['id']);
		$customers = GetCustomers();
		$contactKeywords = GetContactKeywords();
	}
?>

<!DOCTYPE html>
<html lang="en">
	
	<?php include('../inc/head.php'); ?>
	<body>
	<?php include('../inc/navigation.php'); ?>
			<div class="span9">
				<div class="row-fluid">
					<h2>Value: <?=$results['value'] ?></h2>
					
					<form class="well" method="post" action="#">
						<div class="control-group">
			            	<label class="control-label" for="customer_id">Customer:</label>
			             <div class="controls">
			             		<select name="customer_id" id="customer_id">
			             			<?php while($rs = $customers->fetch_assoc()): ?>
			             			<option value="<?=$rs['id'] ?>"><?=$rs['first_name']?> <?=$rs['last_name'] ?></option>
			             			<?php endwhile; ?>
			             		</select>
			               </div>
			            </div>
						<div class="control-group">
			            	<label class="control-label" for="value">Value:</label>
			             <div class="controls">
			                <input type="text" name="value" id="value" value="<?=$results['value']?>"/>
			               </div>
			            </div>
			            <div class="control-group">
			            	<label class="control-label" for="contact_keyword">Contact Keyword:</label>
			             <div class="controls">
			                <select name="contact_keyword" id="contact_keyword">
			             			<?php while($rs = $contactKeywords->fetch_assoc()): ?>
			             			<option value="<?=$rs['id'] ?>"><?=$rs['name']?></option>
			             			<?php endwhile; ?>
			             		</select>
			               </div>
			            </div>
			            <input type="hidden" name="id" value="<?=$_GET['id'] ?>" />
						<input type="submit" name="submit" value="Submit" />
					</form>
				</div>
			</div>
		</div>
	</div>
	
	<!-- All Bootstrap JavaScript Files -->
	<script src="../inc/bootstrap/js/jquery.js"></script>
    <script src="../inc/bootstrap/js/bootstrap.js"></script>
	
	</body>
</html>
